<?php


namespace app\admin\controller;

use app\common\controller\admin\Base;

class Autoreply extends Base
{
    protected $noNeedLogin = [];

    protected $model;


    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\AutoReply();
    }


    /**
     * 查看
     */
    public function index()
    {
        //设置过滤方法
        if ($this->request->isPost()) {
            $page = $this->request->post('page', 1);
            $size = $this->request->post('page_size', 10);
            $where = [
                'is_del' => 0
            ];
            $list = $this->model
                ->field('*')
                ->where($where)
                ->page($page, $size)
                ->order('id', 'desc')
                ->select()
                ->toArray();
            $total = $this->model->where($where)->count('id');
            $totalPage = ceil($total / $size);
            $data = [
                'total' => $total,
                'list' => $list,
                'totalPage' => $totalPage
            ];
            $this->success('列表', '', $data);
        }
    }
}